package com.ruoyi.api.wechat.controller;

import com.ruoyi.common.utils.WechatSignUtil;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/wechat")
public class WechatController {

    @PostMapping("/auth")
    public String validate(
            @RequestParam("signature") String signature,
            @RequestParam("timestamp") String timestamp,
            @RequestParam("nonce") String nonce,
            @RequestParam("echostr") String echostr) {

        if (WechatSignUtil.checkSignature(signature, timestamp, nonce)) {
            return echostr;
        }
        return "invalid request";
    }
}
